package com.xtaller.lazy;


import com.xtaller.lazy.lib.convert.J;
import com.xtaller.lazy.lib.convert.M;
import com.xtaller.lazy.lib.convert.S;
import lombok.var;
import net.sourceforge.pinyin4j.PinyinHelper;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @version V1.0
 * @author: Taller
 * @date: 2019-04-03
 * @Description:
 */
public class Test {
    public static void main(String[] args){

        var list1 = Arrays.asList(1,3,5,7);
        var list2 = Arrays.asList(2,4,6,8);



        // 先找到删除的
        var delete = list1.stream().filter(x -> !list2.contains(x)).collect(Collectors.toList());
        System.out.println(delete);
        // 找到新增的
        var create = list2.stream().filter(x -> !list1.contains(x)).collect(Collectors.toList());
        System.out.println(create);
        // 找到修改项
        Collection realA = new ArrayList<>(list1);
        Collection realB = new ArrayList<>(list2);
        realA.retainAll(realB);
        System.out.println(realA);
    }

    /**
     * 提取每个汉字的首字母
     * @param str
     * @return
     */
    public static String getPinYinHeadChar(String str){
        String convert = "";
        for (int i = 0; i < str.length(); i++) {
            char word = str.charAt(i);
            //提取汉字的首字母
            String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
            if (pinyinArray != null){
                convert += pinyinArray[0].charAt(0);
            }else{
                convert += word;
            }
        }
        return convert.toUpperCase();
    }
}
